﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ETL.Business.Models;
using ETL.Common.Logging;
using ETL.DataAccess;

namespace ETL.Business.Handlers.ProjectTaskHandler
{

    public class UpdateProjectTask
    {
        private readonly ProjectTaskRepository _projectTaskRepository;
        public UpdateProjectTask(ProjectTaskRepository projectTaskRepository)
        {
            _projectTaskRepository = projectTaskRepository;
        }
        public UpdateProjectTask()
        {
            _projectTaskRepository = new ProjectTaskRepository();
        }

        public virtual int Execute(string taskId, string taskName)
        {
            int result = -1;
            try
            {
                result = _projectTaskRepository.UpdateProjectTask(taskId, taskName);
                return result;
            }
            catch (Exception ex)
            {
                LogService.Service.Error(ex);
                return -1;

            }

        }

        public virtual int Execute(ProjectTaskModel task)
        {
            int result = -1;
            try
            {
                result = Execute(task.TaskId.ToString(), task.TaskName);
                return result;
            }
            catch (Exception ex)
            {
                LogService.Service.Error(ex);
                return -1;

            }

        }
    }
}
